/* 
 * File:   Command.h
 * Author: Bram
 *
 * Created on January 13, 2013, 12:25 AM
 */

#ifndef COMMAND_H
#define	COMMAND_H

#include "logger.h"
#include <vector>
#include "pugixml.h"
#include "GeneralSocket.h"
#include <queue>
#include "base64.h"

class Command {
public:
    Command(void);
    virtual Command* createNew() = 0;
    virtual ~Command();
    
    const string& getName();
    void setName(const string&);
    const string& getSender();
    void setSender(const string&);
    const string& getType();
    void setType(const string&);
    
    virtual bool isValid();
    virtual void ExcecuteServerReceiveCommand(TcpSocket* dasSocket, queue<Command *>& commandQueue) = 0;
    virtual void ExcecuteServerSendCommand(TcpSocket* dasSocket, queue<Command *>& commandQueue) = 0;
    
    virtual void ExcecuteClientReceiveCommand(TcpSocket* dasSocket, queue<Command *>& commandQueue) = 0;
    virtual void ExcecuteClientSendCommand(TcpSocket* dasSocket, queue<Command *>& commandQueue) = 0;
    
    void addParameter(const string&);
    void removeParameter(const string&);
    void clearParameters();
    int sizeParameters();
    bool getParameterAtIndex(int, string&);
    bool replaceParameterAtIndex(int, string&);
    
    static Command * parseInputCommand(const string&);
    static Command * ParseOutputCommand(const string&);
    
    static Command * Generate(const string&);

    string buildFullCommand();
    
    Command* getNextCommandFromSocket(TcpSocket*);
    
    Command * Clone();
    bool Clone(Command *);
    
    void PrintFullCout();
    void GetFullCout(string& output, bool allInOneLine);
    
protected:
    Command(const char* szID);
    
private:
    string _name;
    string _sender;
    string _type;
    vector<string> Parameters;

};



#endif	/* COMMAND_H */

